//
//  ZCOrderListBodyBottmCell.m
//  ZCJZ
//
//  Created by sujeking on 2019/3/2.
//  Copyright © 2019年 jeking. All rights reserved.
//

#import "ZCOrderListBodyBottmCell.h"
#import "ZCOrderConst.h"
#import "TBCityIconFont.h"
#import <UIImageView+WebCache.h>
@interface ZCOrderListBodyBottmCell()
@property (weak, nonatomic) IBOutlet UILabel *tiplabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *btn01;
@property (weak, nonatomic) IBOutlet UIButton *btn02;
@property (weak, nonatomic) IBOutlet UIButton *btn03;
@property (weak, nonatomic) IBOutlet UIStackView *sview;
@property (weak, nonatomic) IBOutlet UIImageView *avatar;

@end


@implementation ZCOrderListBodyBottmCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
}

- (void)setupSubViews {
    self.tiplabel.text = @"应付:";
    self.avatar.hidden = YES;
    for (UIButton *btn in self.sview.subviews) {
        btn.layer.cornerRadius = 2.0f;
        btn.layer.masksToBounds = YES;
        btn.layer.borderColor = [generalToolBox getColorWithHexadecimalColorStr:@"0x999999"].CGColor;
        btn.layer.borderWidth = 1.0f;
        [btn setTitleEdgeInsets:(UIEdgeInsets){5,-10,5,10}];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setOtherpay_uid:(NSString *)otherpay_uid {
    _otherpay_uid = otherpay_uid;
    if (otherpay_uid.intValue != 0) {
        self.avatar.hidden = NO;
        self.priceLabel.text = [NSString stringWithFormat:@" 代付: %@",self.priceLabel.text];
    } else {
        self.avatar.hidden = YES;
    }
}

- (void)setOtherpay_avatar:(NSString *)otherpay_avatar {
    _otherpay_avatar = otherpay_avatar;
    [self.avatar sd_setImageWithURL:[NSURL URLWithString:otherpay_avatar]
                   placeholderImage:nil
                            options:SDWebImageAllowInvalidSSLCertificates];
    self.avatar.layer.cornerRadius = CGRectGetHeight(self.avatar.bounds) / 2;
    self.avatar.layer.masksToBounds = YES;
    self.avatar.backgroundColor = [generalToolBox getColorWithHexadecimalColorStr:@"0xf5f5f5"];
}


- (void)setTotalPrice:(NSString *)totalPrice {
    _totalPrice = totalPrice;
    CGFloat price = totalPrice.floatValue;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%.2f",price];
}

- (void)setStatus:(NSInteger)status {
    _status = status;
    self.tiplabel.text = @"应付:";
    switch (status) {
        case STATUS_CANCEL:{
            self.btn01.hidden = YES;
            self.btn02.hidden = YES;
            self.btn03.hidden = YES;
        } break;
        case STATUS_WAIT_PAY:
        {
            self.btn01.hidden = NO;
            self.btn02.hidden = YES;
            self.btn03.hidden = NO;
            [self.btn01 setTitle:@"取消订单" forState:UIControlStateNormal];
            [self.btn02 setTitle:@"删除订单" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"立即支付" forState:UIControlStateNormal];
            [self setButtonsStyle];
          self.btn03.backgroundColor = [generalToolBox getColorWithHexadecimalColorStr:@"0xC20114"];
            [self.btn03 setTitleColor:[UIColor whiteColor]
                             forState:UIControlStateNormal];
            self.btn03.layer.borderColor = [generalToolBox getColorWithHexadecimalColorStr:@"0xC20114"].CGColor;
        } break;
            
        case STATUS_WAIT_SEND:{
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = YES;
            self.btn02.hidden = NO;
            self.btn03.hidden = NO;
            [self.btn02 setTitle:@"订单回执" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"取消订单" forState:UIControlStateNormal];
            [self setButtonsStyle];
        } break;
        case STATUS_WAIT_GET:
        {
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = NO;
            self.btn02.hidden = NO;
            self.btn03.hidden = NO;
            [self.btn01 setTitle:@"订单回执" forState:UIControlStateNormal];
            [self.btn02 setTitle:@"查看物流" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"确认收货" forState:UIControlStateNormal];
            [self setButtonsStyle];
        } break;
        case STATUS_WAIT_FEEDBACK:
        {
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = NO;
            self.btn02.hidden = YES;
            self.btn03.hidden = NO;
            [self.btn01 setTitle:@"订单回执" forState:UIControlStateNormal];
//            [self.btn02 setTitle:@"评价商品" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"再次购买" forState:UIControlStateNormal];
            [self setButtonsStyle];
        } break;
        case STATUS_END:
        {
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = NO;
            self.btn02.hidden = YES;
            self.btn03.hidden = NO;
            [self.btn01 setTitle:@"订单回执" forState:UIControlStateNormal];
//            [self.btn02 setTitle:@"查看评价" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"再次购买" forState:UIControlStateNormal];
            [self setButtonsStyle];
        } break;
        case STATUS_AFTER_SALES:{
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = YES;
            self.btn02.hidden = YES;
            self.btn03.hidden = YES;
        } break;
        case STATUS_CLOSE:
        {
            self.tiplabel.text = @"实付:";
            self.btn01.hidden = YES;
            self.btn02.hidden = YES;
            self.btn03.hidden = NO;
            [self.btn02 setTitle:@"删除订单" forState:UIControlStateNormal];
            [self.btn03 setTitle:@"重新购买" forState:UIControlStateNormal];
            [self setButtonsStyle];
        } break;
        default:
        {
            self.btn01.hidden = YES;
            self.btn02.hidden = YES;
            self.btn03.hidden = YES;
        }
            break;
    }
}

- (IBAction)btn01ClickAction:(id)sender {
    if (self.btn01ClickCallBack) {
        self.btn01ClickCallBack();
    }
}

- (IBAction)btn02ClickAction:(id)sender {
    if (self.btn02ClickCallBack) {
        self.btn02ClickCallBack();
    }
}

- (IBAction)btn03ClickAction:(id)sender {
    if (self.btn03ClickCallBack) {
        self.btn03ClickCallBack();
    }
}


- (void)setButtonsStyle {
    for (UIButton *btn in self.sview.subviews) {
        btn.layer.cornerRadius = 2.0f;
        btn.layer.masksToBounds = YES;
        btn.layer.borderColor = [generalToolBox getColorWithHexadecimalColorStr:@"0x999999"].CGColor;
        btn.layer.borderWidth = 1.0f;
        
        [btn setTitleColor:[generalToolBox getColorWithHexadecimalColorStr:@"0x666666"] forState:UIControlStateNormal];
        [btn setBackgroundColor:[generalToolBox getColorWithHexadecimalColorStr:@"0xffffff"]];
    }
}

@end
